<template>
	<view class="page-content">
		<template v-if="showType==1">
			<mission_detail :data="data" ref="detail" @success="getData" :showBtn="false"></mission_detail>
		</template>
		<template v-else>
			<template v-if="data.is_join==2">
				<mission_detail :data="data" ref="detail" @success="getData"></mission_detail>
			</template>
			<template v-if="data.is_join==1">
				<mission_keyword style="height: 100%;" :detail="data" ref="mKw"></mission_keyword>
			</template>
		</template>
	</view>
</template>

<script>
	import {
		getMissionDetail
	} from '@/config/api.js'

	export default {
		data() {
			return {
				id: "",
				data: null,
				apiToken: "",
				user: null,
				showType: 1
			}
		},
		onLoad(op) {
			this.id = op.id;
			this.showType = op.showType;
		},
		onShow() {
			this.user = uni.getStorageSync('UserInfo');
			this.getData();
		},
		methods: {
			getData() {
				getMissionDetail({
					id: this.id,
					user_id: this.user ? this.user.id : ""
				}).then(res => {
					this.data = res
					uni.setNavigationBarTitle({
						title: res.name
					})
					this.$nextTick(() => {
						if (this.$refs.mKw)
							this.$refs.mKw.setData(res);
					})
				}).catch(err => {

				})
			}
		}
	}
</script>

<style scoped>

</style>
